home *** CD-ROM | disk | FTP | other *** search
/ Light ROM 1 / LIGHT-ROM 1 (Amiga Library Services)(1994).iso / ffdisks / d939.lha / ExtraCmds / source_etc.lha / src / severalnames.c < prev    next >
C/C++ Source or Header  |  1993-10-22  |  3KB  |  86 lines

  1. /*   ---------------------------------      -------     
  2.  *   |\  | | | | |  |.| |   \|  |/ /|\      |||||||     
  3.  *   | | | |/  | |\ |/  |/|  |\ |/  |    ?  ---+---  =< 
  4.  *   | | | |   | |  |     |  |  |   |     \qqqqqqqqq/   
  5.  *   ---------------------------------  ~~~~~~~~~~~~~~~~
  6.  *
  7.  *  severalnames() - A hack to determine if more than one name is
  8.  *                   specified for a /M argument. The presence of
  9.  *                   a pattern is taken to mean that there is more
  10.  *                   than one name (even if it doesn't match anything!)
  11.  *
  12.  *                   Doesn't report a malformed pattern, as it will be
  13.  *                   caught by a subsequent call to a pattern matching 
  14.  *                   function like foreach().
  15.  *  
  16.  *  Copyright (C) 1993 Torsten Poulin
  17.  *
  18.  *  This file is part of "Torsten's AmigaDOS Shell Commands" package.
  19.  *  The package is free software; you can redistribute it and/or modify
  20.  *  it under the terms of the GNU General Public License as published by
  21.  *  the Free Software Foundation; either version 2 of the License, or
  22.  *  (at your option) any later version.
  23.  *
  24.  *  The package is distributed in the hope that it will be useful,
  25.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  26.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  27.  *  GNU General Public License for more details.
  28.  *
  29.  *  You should have received a copy of the GNU General Public License
  30.  *  along with this program; if not, write to the Free Software
  31.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  32.  *
  33.  *  The author can be contacted by s-mail at
  34.  *    Torsten Poulin
  35.  *    Banebrinken 99, 2, 77
  36.  *    DK-2400 Copenhagen NV
  37.  *    DENMARK
  38.  *
  39.  * $Id: severalnames.c,v 1.2 93/03/01 13:02:22 Torsten Rel $
  40.  * $Log:    severalnames.c,v $
  41.  * Revision 1.2  93/03/01  13:02:22  Torsten
  42.  * Changed all occurrences of "struct DosBase *" to "struct DosLibrary *"
  43.  * 
  44.  * Revision 1.1  93/03/01  11:04:48  Torsten
  45.  * Initial revision
  46.  * 
  47.  */
  48.  
  49. #include <exec/types.h>
  50. #include <exec/memory.h>
  51. #include <dos/dos.h>
  52. #include <dos/dosasl.h>
  53. #include <clib/dos_protos.h>
  54. #include <clib/exec_protos.h>
  55. #ifdef __SASC
  56. #include <pragmas/dos_pragmas.h>
  57. #include <pragmas/exec_pragmas.h>
  58. #endif
  59. #include <string.h>
  60. #include "tastlib.h"
  61.  
  62. struct Global {
  63.   struct DosLibrary *DOSBase;
  64. };
  65.  
  66. ULONG severalnames(UBYTE **arg, VOID *global)
  67. {
  68.   struct DosLibrary *DOSBase = ((struct Global *) global)->DOSBase;
  69.   UBYTE *dest;
  70.   UBYTE **args;
  71.   ULONG several = 0L;
  72.   ULONG length;
  73.  
  74.   args = arg;
  75.   for (; *args; args++, several++)
  76.     if (several)
  77.       return TRUE;
  78.  
  79.   length = 2 * strlen(*arg) + 2;
  80.   if (!(dest = AllocVec(length + 1, MEMF_PUBLIC)))
  81.     several = ERROR_NO_FREE_STORE;
  82.   several = ParsePattern(*arg, dest, length) > 0 ? TRUE : FALSE;
  83.   FreeVec(dest);
  84.   return several;
  85. }
  86.